"use server";

import _ from "lodash";
import { getSessionFromNextCookies } from "@/server/service/session-service";
import { cookies } from "next/headers";
import { User } from "@prisma/client";
import { wrapAction } from "@/server/wrapper";

export async function getMe() {
  return await wrapAction(async (): Promise<User> => {
    const session = await getSessionFromNextCookies(cookies());
    return await session.getMe();
  });
}

export async function isAuthenticated() {
  return await wrapAction(async (): Promise<boolean> => {
    const session = await getSessionFromNextCookies(cookies());
    return session.authenticated;
  });
}
